package action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import model.bo.DiscussBO;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 * Action Class ExampleXMLAction
 */
public class DeleteChatAction extends Action {

	/**
	 * Method execute
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		HttpSession session = request.getSession();
		String message = "";
		message = request.getParameter("message");
		String userName = request.getParameter("userName");
		int groupId = Integer.parseInt((String)session.getAttribute("groupId"));
		System.out.println(userName);
		int chatId = Integer.parseInt(request.getParameter("chatId"));
		DiscussBO discussBo = new DiscussBO();
//		AccountManagerBO accountBo = new AccountManagerBO();
		if(groupId==1){
			if("xoa binh luan".equals(message)){
				System.out.println("Thuc hien xoa binh luan");
						
						discussBo.DeleteChat(chatId);
						System.out.println("Thuc hien xoa binh luan co ID: "+chatId);
					}
//					response.getWriter().write(user);
//					response.getWriter().write((String)session.getAttribute("groupId"));
//					response.setStatus(Integer.valueOf((String)session.getAttribute("groupId")));
				else response.getWriter().write("error");
		}
		return null;
	}
}
